function exportRouterSql(root, baseId=1, platformId = 1) {
    let currentId = baseId;
    function iter(list, parent){
        return list.flatMap(record => {
            if (record.meta && record.meta.label) {
                const cur = {
                    id: currentId++,
                    platformId,
                    name: record.name,
                    levelId: parent ? parent.levelId + 1 : 1,
                    parentId: parent? parent.id : 0,
                    url: `${parent ? parent.url : ''}/${record.path}`,
                    description: record.meta.label,
                };
                const child = [];
                if (record.children) child.push(...iter(record.children, cur));
                return [cur, ...child];
            }
            return [];
        });
    }
    const formattedList = iter(root, null);
    const nowDate = new Date();
    const prefix =  '-- -------------------------------------\n'+
                    '-- \t前端路由表\n'+
                    `-- 创建日期: ${nowDate.toLocaleString()}\n`+
                    `-- 路由表大小: ${formattedList.length}\n`+
                    '-- -------------------------------------\n';
    const sqlPrefix = "INSERT INTO t_authorization (id, platform_id, name, level_id, parent_id, url, description, update_time, create_time) VALUE";
    const sqlList = formattedList.map(def=>`${sqlPrefix} (${def.id}, ${def.platformId}, '${def.name}', ${def.levelId}, ${def.parentId}, '${def.url}', '${def.description}', NOW(), NOW());\n`);
    const logStr = prefix.concat(...sqlList);
    console.log(logStr);
}

export default {
    exportRouterSql,
};
